AMBARI-26620: Fix LDAPS setup, sync, and login failures on Ambari 3.0 #4151
Open
manish-m-pillai-ksolves wants to merge 1 commit into
Open
AMBARI-26620: Fix LDAPS setup, sync, and login failures on Ambari 3.0 #4151manish-m-pillai-ksolves wants to merge 1 commit into
manish-m-pillai-ksolves wants to merge 1 commit into
Conversation
Three bugs blocked the full LDAPS setup flow on Ambari 3.0: 1. serverUtils.py: Encode POST body to bytes in perform_changes_via_rest_api() Python 3's urllib requires bytes for request.data; json.dumps() returns str. 2. setupSecurity.py: Same encoding fix for both POST bodies in sync_ldap() Fixes 'POST data should be of type str' error during ambari-server sync-ldap. 3. ambari-env.sh: Add --add-opens java.naming/com.sun.jndi.ldap=ALL-UNNAMED Java 9+ module system blocked Spring LDAP's reflective access to LdapCtxFactory, causing IllegalAccessError on LDAP login via the UI. Updated 8 sync_ldap unit test assertions in TestAmbariServer.py to expect bytes instead of str, keeping the test suite consistent with the fix. Fixes: ambari-server setup-ldap, sync-ldap --all, and LDAP UI authentication.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
Three bugs blocked the full LDAPS setup flow end-to-end on Ambari 3.0
(Python 3, Java 9+):
serverUtils.py — Encode POST body to bytes in
perform_changes_via_rest_api(). Python 3'surllibrequiresbytesfor
request.data;json.dumps()returns astr, causingambari-server setup-ldapto fail withTypeError: POST data should be bytes, an iterable of bytes, or a file object. It cannot be of type str.while saving LDAP configuration.setupSecurity.py — Same encoding fix applied to both POST bodies in
sync_ldap(). Fixes the identicalPOST data should be byteserrorduring
ambari-server sync-ldap --all, which occurs in a separate codepath from (1) and was not covered by the existing AMBARI-26062 fix
(which only patched
configs.py).ambari-env.sh — Added
--add-opens java.naming/com.sun.jndi.ldap=ALL-UNNAMEDtoAMBARI_JVM_ARGS. On Java 9+, the module system blocks Spring LDAP'sreflective access to the JDK-internal class
com.sun.jndi.ldap.LdapCtxFactory, causingIllegalAccessError/NoClassDefFoundErroron every LDAP login attemptvia the Ambari UI. Ambari's default JVM args already open several
java.basepackages for the same reason;java.namingwas missing.Also updated 8
sync_ldap-related unit test assertions inTestAmbariServer.pyto expectbytesinstead ofstr, keeping the testsuite consistent with fix (2).
Together these three fixes unblock
ambari-server setup-ldap,ambari-server sync-ldap --all, and LDAP authentication via the AmbariUI, which were all broken on a fresh Ambari 3.0 install running Python 3
and Java 9+.
How was this patch tested?
sync_ldapassertions inTestAmbariServer.pyto assertbytesrequest bodies; full test modulepasses after the change.
Java 17) against an OpenLDAP server:
ambari-server setup-ldap -vwith SSL enabled — configurationnow saves successfully (previously failed with the
TypeErrorabove).
ambari-server sync-ldap --all— sync now completessuccessfully, confirmed by summary output showing groups/users
created (previously failed with the sync event creation error).
now succeeds (previously failed with the Java
IllegalAccessError/NoClassDefFoundErrorinambari-server.log).perform_changes_via_rest_api()callers continue to work, since the fixonly changes how the body is encoded, not the request logic itself.